﻿@using SmartStore.Web.Framework.UI;
@model LanguageModel

@Html.ValidationSummary(false)
@Html.HiddenFor(model => model.Id)
@Html.SmartStore().TabStrip().Name("language-edit").Style(TabsStyle.Material).Position(TabsPosition.Top).Items(x =>
{
	x.Add().Text(T("Admin.Common.Info").Text).Content(TabInfo()).Selected(true);
	x.Add().Text(T("Admin.Common.Stores").Text).Content(TabStores());

    //generate an event
	EngineContext.Current.Resolve<IEventPublisher>().Publish(new TabStripCreated(x, "language-edit", this.Html, this.Model));
})

@helper TabInfo()
{
	<table id="LanguageEditTable" class="adminContent">
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.Name)
			</td>
			<td class="adminData">
				@Html.EditorFor(model => model.Name)
				@Html.ValidationMessageFor(model => model.Name)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.LanguageCulture)
			</td>
			<td class="adminData">
				@Html.DropDownListFor(x => x.LanguageCulture, Model.AvailableCultures)
				@Html.ValidationMessageFor(model => model.LanguageCulture)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.UniqueSeoCode)
			</td>
			<td class="adminData">
				@Html.DropDownListFor(x => x.UniqueSeoCode, Model.AvailableTwoLetterLanguageCodes)
				@Html.ValidationMessageFor(model => model.UniqueSeoCode)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.FlagImageFileName)
			</td>
			<td class="adminData">
				<select name="FlagImageFileName" data-placeholder="@T("Common.Unspecified")">
					<option></option>
					@foreach (var item in Model.AvailableFlags)
					{
						var select = item.Value.IsCaseInsensitiveEqual(Model.FlagImageFileName);
						<option data-imageurl='@Url.Content("~/Content/Images/flags/")@item.Value' value="@item.Value" @(select ? "selected='selected'" : "")>@item.Text</option>
					}
				</select>
				@Html.ValidationMessageFor(model => model.FlagImageFileName)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.Rtl)
			</td>
			<td class="adminData">
				@Html.EditorFor(model => model.Rtl)
				@Html.ValidationMessageFor(model => model.Rtl)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.Published)
			</td>
			<td class="adminData">
				@Html.EditorFor(model => model.Published)
				@Html.ValidationMessageFor(model => model.Published)
			</td>
		</tr>
		<tr>
			<td class="adminTitle">
				@Html.SmartLabelFor(model => model.DisplayOrder)
			</td>
			<td class="adminData">
				@Html.EditorFor(model => model.DisplayOrder)
				@Html.ValidationMessageFor(model => model.DisplayOrder)
			</td>
		</tr>
		@if (Model.LastResourcesImportOnString.HasValue())
		{
			<tr>
				<td class="adminTitle">
					@Html.SmartLabelFor(model => model.LastResourcesImportOnString)
				</td>
				<td class="adminData">
					@Html.TextBoxFor(model => model.LastResourcesImportOnString, new { @readonly = "readonly", @class = "form-control-plaintext" })
				</td>
			</tr>
		}
	</table>
}

@helper TabStores()
{
	@Html.Partial("StoreSelector", Model)
}